what is select
weather_df =
rnoaa::meteo_pull_monitors(
c("USW00094728", "USC00519397", "USS0023B17S"),
var = c("PRCP", "TMIN", "TMAX"),
date_min = "2017-01-01",
date_max = "2017-12-31") %>%
mutate(
name = recode(
id,
USW00094728 = "CentralPark_NY",
USC00519397 = "Waikiki_HA",
USS0023B17S = "Waterhole_WA"),
tmin = tmin / 10,
tmax = tmax / 10) %>%
select(name, id, everything())
## Registered S3 method overwritten by 'hoardr':
## method from
## print.cache_info httr
## using cached file: ~/Library/Caches/R/noaa_ghcnd/USW00094728.dly
## date created (size, mb): 2022-09-29 09:14:18 (8.401)
## file min/max dates: 1869-01-01 / 2022-09-30
## using cached file: ~/Library/Caches/R/noaa_ghcnd/USC00519397.dly
## date created (size, mb): 2022-09-29 09:14:20 (1.699)
## file min/max dates: 1965-01-01 / 2020-03-31
## using cached file: ~/Library/Caches/R/noaa_ghcnd/USS0023B17S.dly
## date created (size, mb): 2022-09-29 09:14:22 (0.95)
## file min/max dates: 1999-09-01 / 2022-09-30
weather_scatterplot=
weather_df %>%
drop_na() %>%
filter(name == "CentralPark_NY") %>%
ggplot(aes(x = tmin, y = tmax)) +
geom_point()
weather_scatterplot

# about color moving around_same
ggplot(weather_df, aes(x = tmin, y = tmax, color = name)) +
geom_point()
## Warning: Removed 15 rows containing missing values (geom_point).

ggplot(weather_df, aes(x = tmin, y = tmax)) +
geom_point(aes(color = name))
## Warning: Removed 15 rows containing missing values (geom_point).

# about color moving around_different
ggplot(weather_df, aes(x = tmin, y = tmax)) +
geom_point(aes(color = name), alpha = .5) +
geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Removed 15 rows containing missing values (geom_point).

ggplot(weather_df, aes(x = tmin, y = tmax, color = name)) +
geom_point() +
geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Removed 15 rows containing missing values (geom_point).

# seperate panels
ggplot(weather_df, aes(x = tmin, y = tmax, color = name)) +
geom_point(alpha = .5) +
geom_smooth(se = FALSE) +
facet_grid(. ~ name)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Removed 15 rows containing missing values (geom_point).

# another way of the last line!!
ggplot(weather_df, aes(x = date, y = tmax, color = name)) +
geom_point(aes(size = prcp), alpha = .5) +
geom_smooth(se = FALSE) +
facet_grid(. ~ name)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Warning: Removed 3 rows containing missing values (geom_point).

weather_df %>%
ggplot(aes(x = date, y = tmax, color = name))+
geom_point(aes(size = prcp), alpha = .3)+
geom_smooth(se = FALSE)+
facet_grid(. ~ name)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).
## Removed 3 rows containing missing values (geom_point).

weather_df %>%
mutate(COVERT TO FAHRENHEIT)
ggplot(weather_df, aes(x = date, y = tmax, color = name)) +
geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 3 rows containing non-finite values (stat_smooth).

ggplot(weather_df, aes(x = tmax, y = tmin)) +
geom_hex()
## Warning: Removed 15 rows containing non-finite values (stat_binhex).

ggplot(weather_df, aes(x = tmax)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).

weather_df %>%
ggplot(aes(x = tmax, fill = name))+
geom_histogram()+
facet_grid(. ~ name)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).

ggplot(weather_df, aes(x = tmax, color = name)) +
geom_histogram(position = "dodge", binwidth = 2)
## Warning: Removed 3 rows containing non-finite values (stat_bin).

ggplot(weather_df, aes(x = tmax, fill = name)) +
geom_density(alpha = .4, adjust = .5, color = "blue")
## Warning: Removed 3 rows containing non-finite values (stat_density).

ggplot(weather_df, aes(x = name, y = tmax)) + geom_boxplot()
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).

weather_df %>%
drop_na() %>%
ggplot(aes(y = tmax))+
geom_boxplot()

# use violinplot when having many groups for comparing
ggplot(weather_df, aes(x = name, y = tmax)) +
geom_violin(aes(fill = name), alpha = .5) +
stat_summary(fun = "median", color = "blue")
## Warning: Removed 3 rows containing non-finite values (stat_ydensity).
## Warning: Removed 3 rows containing non-finite values (stat_summary).
## Warning: Removed 3 rows containing missing values (geom_segment).

ggplot(weather_df, aes(x = tmax, y = name)) +
geom_density_ridges(scale = .85)
## Picking joint bandwidth of 1.84
## Warning: Removed 3 rows containing non-finite values (stat_density_ridges).

weather_df %>%
ggplot(aes(x = tmax, y= name))+
geom_density_ridges(scale = 5)
## Picking joint bandwidth of 1.84
## Warning: Removed 3 rows containing non-finite values (stat_density_ridges).

weather_scatterplot=
weather_df %>%
drop_na() %>%
filter(name == "CentralPark_NY") %>%
ggplot(aes(x = tmin, y = tmax)) +
geom_point()
ggsave(
"results/scatterplot.pdf", weather_scatterplot,
width = 5)
## Saving 5 x 5 in image
weather_scatterplot
